"""
1. 定义访问Pika的请求对象
"""
from typing import Optional

from pydantic import BaseModel, model_validator, field_validator

from utils.comm1507 import singleton


class PikaBaseRequest(BaseModel):
    orgid: int
    medcasno: str
    adm_date: Optional[str] = None
    dscg_date: Optional[str] = None


class Qry_Detail_Mgr:
    def __init__(self):
        super().__init__()

    def do_req(self, req: PikaBaseRequest):
        pass

    def main(self, req: PikaBaseRequest):
        results, all_rowcount = self.do_req(req)
        return {
            "succ": True,
            "errcode": 0,
            "msg": "ok",
            "results": results,
            "total_count": all_rowcount
        }


@singleton
class QryDetailMgrFactory:
    def __init__(self):
        self.mgr = Qry_Detail_Mgr()

    def get_mgr(self):
        return self.mgr
